/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import javax.swing.JOptionPane;

/**
 *
 * @author Tiago
 */
public class MedicamentoView extends javax.swing.JDialog {
    //variável para diferenciar alteração de inclusão. Inclusão = False, Alteração = True
    boolean alterar;
    int codigo;
    
    public MedicamentoView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo( null );
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnMedicamentoCampo = new javax.swing.JPanel();
        tfMedicamentoNome = new javax.swing.JTextField();
        tfMedicamentoFormaFarmaceutica = new javax.swing.JTextField();
        tfMedicamentoCaracteristica = new javax.swing.JTextField();
        tfMedicamentoPrincipioAtivo = new javax.swing.JTextField();
        cbMedicamentoVia = new javax.swing.JComboBox();
        lbMedicamentoNome = new javax.swing.JLabel();
        lbMedicamentoForma = new javax.swing.JLabel();
        lbMedicamentoCaracteristica = new javax.swing.JLabel();
        lbMedicamentoPrincipioAtivo = new javax.swing.JLabel();
        lbMedicamentoVia = new javax.swing.JLabel();
        pnMedicamentoBotao = new javax.swing.JPanel();
        btMedicamentoSalvar = new javax.swing.JButton();
        btMedicamentoCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Medicamento");
        setModal(true);
        setResizable(false);

        pnMedicamentoCampo.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Medicamento"));

        tfMedicamentoNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfMedicamentoNomeKeyReleased(evt);
            }
        });

        tfMedicamentoFormaFarmaceutica.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfMedicamentoFormaFarmaceuticaKeyReleased(evt);
            }
        });

        tfMedicamentoCaracteristica.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfMedicamentoCaracteristicaKeyReleased(evt);
            }
        });

        tfMedicamentoPrincipioAtivo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfMedicamentoPrincipioAtivoKeyReleased(evt);
            }
        });

        cbMedicamentoVia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Oral", "Via 2", "Via 3" }));

        lbMedicamentoNome.setText("Nome:");

        lbMedicamentoForma.setText("Forma Farmacêutica:");

        lbMedicamentoCaracteristica.setText("Característica:");

        lbMedicamentoPrincipioAtivo.setText("Princípio Ativo:");

        lbMedicamentoVia.setText("Via de Aplicação:");

        javax.swing.GroupLayout pnMedicamentoCampoLayout = new javax.swing.GroupLayout(pnMedicamentoCampo);
        pnMedicamentoCampo.setLayout(pnMedicamentoCampoLayout);
        pnMedicamentoCampoLayout.setHorizontalGroup(
            pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMedicamentoCampoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lbMedicamentoNome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbMedicamentoForma, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbMedicamentoCaracteristica, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbMedicamentoPrincipioAtivo)
                    .addComponent(lbMedicamentoVia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tfMedicamentoNome, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
                    .addComponent(tfMedicamentoFormaFarmaceutica)
                    .addComponent(tfMedicamentoCaracteristica)
                    .addComponent(tfMedicamentoPrincipioAtivo)
                    .addComponent(cbMedicamentoVia, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        pnMedicamentoCampoLayout.setVerticalGroup(
            pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMedicamentoCampoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfMedicamentoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbMedicamentoNome))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfMedicamentoFormaFarmaceutica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbMedicamentoForma))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfMedicamentoCaracteristica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbMedicamentoCaracteristica))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfMedicamentoPrincipioAtivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbMedicamentoPrincipioAtivo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnMedicamentoCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbMedicamentoVia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbMedicamentoVia))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnMedicamentoBotao.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btMedicamentoSalvar.setText("Salvar");
        btMedicamentoSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMedicamentoSalvarActionPerformed(evt);
            }
        });

        btMedicamentoCancelar.setText("Cancelar");
        btMedicamentoCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMedicamentoCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnMedicamentoBotaoLayout = new javax.swing.GroupLayout(pnMedicamentoBotao);
        pnMedicamentoBotao.setLayout(pnMedicamentoBotaoLayout);
        pnMedicamentoBotaoLayout.setHorizontalGroup(
            pnMedicamentoBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnMedicamentoBotaoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btMedicamentoSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btMedicamentoCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(103, 103, 103))
        );
        pnMedicamentoBotaoLayout.setVerticalGroup(
            pnMedicamentoBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMedicamentoBotaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnMedicamentoBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btMedicamentoSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btMedicamentoCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(pnMedicamentoBotao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnMedicamentoCampo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnMedicamentoCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnMedicamentoBotao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btMedicamentoCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMedicamentoCancelarActionPerformed
        this.dispose();
    }//GEN-LAST:event_btMedicamentoCancelarActionPerformed

    private void btMedicamentoSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMedicamentoSalvarActionPerformed
        if((tfMedicamentoNome.getText().equals("")) || (tfMedicamentoFormaFarmaceutica.getText().equals("")) || (tfMedicamentoPrincipioAtivo.getText().equals(""))){
            JOptionPane.showMessageDialog(null, "Preencha os campos corretamente!");
        }
        else{
            if(alterar == false){
                //Inclui
            }
            else{
                //Altera
            }
        }
    }//GEN-LAST:event_btMedicamentoSalvarActionPerformed

    private void tfMedicamentoNomeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfMedicamentoNomeKeyReleased
        tfMedicamentoNome.setText(tfMedicamentoNome.getText().toUpperCase());
    }//GEN-LAST:event_tfMedicamentoNomeKeyReleased

    private void tfMedicamentoFormaFarmaceuticaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfMedicamentoFormaFarmaceuticaKeyReleased
        tfMedicamentoFormaFarmaceutica.setText(tfMedicamentoFormaFarmaceutica.getText().toUpperCase());
    }//GEN-LAST:event_tfMedicamentoFormaFarmaceuticaKeyReleased

    private void tfMedicamentoCaracteristicaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfMedicamentoCaracteristicaKeyReleased
        tfMedicamentoCaracteristica.setText(tfMedicamentoCaracteristica.getText().toUpperCase());
    }//GEN-LAST:event_tfMedicamentoCaracteristicaKeyReleased

    private void tfMedicamentoPrincipioAtivoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfMedicamentoPrincipioAtivoKeyReleased
        tfMedicamentoPrincipioAtivo.setText(tfMedicamentoPrincipioAtivo.getText().toUpperCase());
    }//GEN-LAST:event_tfMedicamentoPrincipioAtivoKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MedicamentoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MedicamentoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MedicamentoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MedicamentoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                MedicamentoView dialog = new MedicamentoView(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btMedicamentoCancelar;
    private javax.swing.JButton btMedicamentoSalvar;
    private javax.swing.JComboBox cbMedicamentoVia;
    private javax.swing.JLabel lbMedicamentoCaracteristica;
    private javax.swing.JLabel lbMedicamentoForma;
    private javax.swing.JLabel lbMedicamentoNome;
    private javax.swing.JLabel lbMedicamentoPrincipioAtivo;
    private javax.swing.JLabel lbMedicamentoVia;
    private javax.swing.JPanel pnMedicamentoBotao;
    private javax.swing.JPanel pnMedicamentoCampo;
    private javax.swing.JTextField tfMedicamentoCaracteristica;
    private javax.swing.JTextField tfMedicamentoFormaFarmaceutica;
    private javax.swing.JTextField tfMedicamentoNome;
    private javax.swing.JTextField tfMedicamentoPrincipioAtivo;
    // End of variables declaration//GEN-END:variables
}
